
<body>
<form method="post" action="commandeProduit">
Nombre d'article : <input type="number" name="nbr"  value="0"><br>		
  
<p>
	<select name="nom" size="1">
		<?php 
				$link = mysql_connect('localhost','root');
				mysql_set_charset('utf8');
				mysql_select_db('fromagerie',$link);
				
				
				$sql=" SELECT pro_nom FROM tb_produit ";
				$req=mysql_query($sql);
				
				while($data = mysql_fetch_assoc($req))
				{	
					 echo "<option>".$data['pro_nom']."</option>";					
				}
			
				mysql_close();
			?>	
	</select>
	
	<select name="poids" size="1">
		<?php 
				$link = mysql_connect('localhost','root');
				mysql_set_charset('utf8');
				mysql_select_db('fromagerie',$link);
				
				
				$sql=" SELECT emb_poids FROM tb_emballage ";
				$req=mysql_query($sql);
				
				while($data = mysql_fetch_assoc($req))
				{	
					 echo "<option>".$data['emb_poids']."</option>";					
				}
			
				mysql_close();
			?>	
	</select>

</p>    
      
<input type="submit" value="OK">
</form>

<?php 
	
		$nbr = $_POST['nbr'];
		$nom = $_POST['nom'];
		$poids = $_POST['poids'];

	
		
		echo $nbr," fois","   ",$nom," ";
		
		
		$link = mysql_connect('localhost','root');
		mysql_select_db('fromagerie',$link);
		
		$sql=" SELECT pro_id FROM tb_produit WHERE pro_nom='$nom' ";
		$req=mysql_query($sql);
		
		//pro_id
		while($data = mysql_fetch_assoc($req))
		{
			$id= $data['pro_id'];
		}
		
		//emb_prix
		$sql=" SELECT emb_prix FROM tb_emballage WHERE emb_fk_id_pro='$id' AND emb_poids='$poids' ";
		$req=mysql_query($sql);
		
		while($data = mysql_fetch_assoc($req))
		{
			$prix= $data['emb_prix']*$nbr." CHF";
			echo $prix;
		}
		
		
		
		
			
		mysql_close();
		
		
		
?>
</body>